<!DOCTYPE html>

<html lang="zh-cn" xmlns:th="http://www.thymeleaf.org/">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <meta name="description" content="">
    <meta name="author" content="">
    <title>数据</title>
    <!-- Bootstrap JQ核心CSS 、JS-->
    <script src="/static/jquery/3.5.1/jquery.min.js" type="text/javascript"></script>
    <link href="/static/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <script src="/static/bootstrap/3.3.7/js/bootstrap.min.js" type="text/javascript"></script>
    <script src="/static/linling-core-tools/js/linling-core-tools.js" type="text/javascript"></script>
    <!-- 适用于Surface /台式机Windows 8错误的IE10视口黑客 -->
    <script src="/static/linling-core-tools/js/ie10-viewport-bug-workaround.js" type="text/javascript"></script>
    <link href="/static/linling-core-tools/css/ie10-viewport-bug-workaround.css" rel="stylesheet">
    <script type="text/javascript">
        let year = "2021";
        let term = "3";
        let depart = "all";
        let nowPage = 1;
        let sumPage = 1;
        let key = "";

        $(function () {
            refData();
        })


        function refData() {
            year = $("#year").val()
            term = $("#term").val()
            depart = $("#department").val()
            nowPage = parseInt($("#pageNum").html());
            sumPage = parseInt($("#pages").html());
            key = $("#nameKey").val();
        }

        function search() {
            refData();
            location.href = "/course/manage/" + year + "/" + term + "?depart="+depart+"&key=" + key;
        }

        function renew() {
            location.href = "/course/manage/" + year + "/" + term;
        }

        function page(page) {
            refData();
            if (page > sumPage) {
                alert("已经是最后一页！");
                return;
            }
            if (page < 1) {
                alert("已经是第一页！")
                return;
            }
            location.href = "/course/manage/" + year + "/" + term + "?depart=" + depart + "&key=" + key + "&page=" + page;
        }

        function goto() {
            refData();
            location.href = "/course/manage/" + year + "/" + term + "?depart=" + depart + "&key=" + key;
        }
    </script>
</head>
<body>
<h1 class="page-header">课表管理</h1>
<span>条件切换</span>
<label for="year" class="form-inline">
    <select class="bootstrap-select form-control" data-style="btn-info" id="year" name="year">
        <option value="all" th:value="${year}" th:text="'当前学年：'+${year}">默认all</option>
        <option value="all">全部学年(all)</option>
        <option value="2017">2017</option>
        <option value="2018">2018</option>
        <option value="2019">2019</option>
        <option value="2020">2020</option>
        <option value="2021">2021</option>
        <option value="2022">2022</option>
        <option value="2023">2023</option>
        <option value="2024">2024</option>
        <option value="2025">2025</option>
        <option value="2026">2026</option>
    </select>
</label>
<label for="term" class="form-inline">
    <select class="bootstrap-select form-control" data-style="btn-info" id="term" name="term">
        <option value="all" th:value="${term}" th:text="'当前学期：'+${term}">默认全部学期（all)</option>
        <option value="3">上学期（3月）</option>
        <option value="12">下学期（12月）</option>
        <option value="all">全部学期（all)</option>
    </select>
</label>
<label for="department" class="form-inline">
    <select class="bootstrap-select form-control" data-style="btn-info" id="department" name="department">
        <option value="all" th:value="${depart}"
                th:text="'当前部门:'+${depart}">全部部门
        </option>
        <option value="all">全部部门</option>
        <option value="新媒体">新媒体</option>
        <option value="主席团">主席团</option>
        <option value="播主部">播主部</option>
        <option value="编导部">编导部</option>
        <option value="记者部">记者部</option>
        <option value="摄制部">摄制部</option>
        <option value="质检部">质检部</option>
        <option value="外联部">外联部</option>
    </select>
</label>
<button id="switch" class="btn btn-primary" onclick="goto()">
    <span class="glyphicon glyphicon-refresh"></span> 切换
</button>&nbsp;
<br/>
<!-- 搜索 -->
<span>搜索姓名：</span>
<label for="nameKey" class="form-inline">
    <input type="text" id="nameKey" class="form-control" th:value="${key}">&nbsp;&nbsp;
</label>
<button id="search" class="btn btn-primary" onclick="search()">
    <span class="glyphicon glyphicon-search"></span> 搜索
</button>&nbsp;
<button id="reset" class="btn btn-danger" onclick="renew()">
    <span class="glyphicon glyphicon-repeat"></span> 恢复
</button>
<a href="/course/manage/unload/2020/12">
    <button class="btn btn-success">
        <span class="glyphicon glyphicon-bookmark"></span> 未录入查询
    </button>
</a>&nbsp;
<br/>
共找到<span id="sumRows" style="color: crimson" th:text="${count}"></span>条数据&nbsp;
本页共<span style="color: crimson" th:text="${content.size()}"></span>条
<br>
<div class="table-responsive">
    <table id="listCustomer" class="table">
        <thead>
        <tr>
            <th>学号</th>
            <th>姓名</th>
            <th>部门</th>
            <th>学年</th>
            <th>学期</th>
            <th>节次</th>
            <th>操作</th>
            <th>更新时间</th>
        </tr>
        </thead>
        <tbody id="searchVar">
        <!-- 预留数据 -->
        <tr th:each="row:${content}">
            <td th:text="${row.getSid()}"></td>
            <td th:text="${row.getName()}"></td>
            <td th:text="${row.getDepart()}"></td>
            <td th:text="${row.getYear()}"></td>
            <td th:text="${row.getTerm()}"></td>
            <td th:text="'共'+${row.getCourses().size()}+'节'"></td>
            <td>
                <p><a href="#"
                      th:href="'/course/info/'+${row.getId()}+'?year='+${row.getYear()}+'&term='+${row.getTerm()}">详情</a>
                </p>
                <p><a href="#" th:href="'/course/manage/delete?id='+${row.getCid()}">删除</a>
                </p>
            </td>
            <td th:text="${row.getDateTime()}"></td>
        </tr>

        </tbody>
        <tfoot>
        <!-- 尾部数据 -->
        <tr></tr>
        </tfoot>
    </table>
</div>

<div class="icon-align-center">
    <a href="#" id="start" onclick="page(1)">首页</a>
    <button id="upon" onclick="page(nowPage-1)">上一页</button>&nbsp;
    第<span id="pageNum" style="color: #142fdc" th:text="${page}"></span>页&nbsp;
    共<span id="pages" th:text="${pageCount}"></span>页&nbsp;
    <button id="next" onclick="page(nowPage+1)">下一页</button>&nbsp;
    <a href="#" id="last" onclick="page(sumPage)">末页</a>
</div>
</body>
</html>